<?php
/**
 * Create date    : 04/10/2012
 * Description    : Me Controller
 * Version update : 04/10/2012
 */ 
class Me_Controller_Action extends Zend_Controller_Action
{
    public $_Model = '';
	function init()
	{
            parent::init();	
            //Get module name
            $moduleName = $this->_request->getModuleName();
                        
            //Get base url 
            $baseUrl = $this->_request->getBaseUrl();
            //Set layout option
            $option = array (
                    "layout" => "index",
                    "layoutPath" => APPLICATION_PATH."/../public/$moduleName"
            );
            Zend_Layout::startMVC($option);
            //Get config header
            $con = new Zend_Config_Ini(APPLICATION_PATH."/../public/$moduleName/install.ini", "template");

            //Add css
            $arrCss = explode( '|', $con->cssname );
            foreach( $arrCss as $cssName )
            {
                    $cssUrl = $baseUrl."/public/$moduleName/$con->cssdir/$cssName";
                    $this->view->headLink()->appendStylesheet($cssUrl);
            }

            //Add Js common
            $arrJsCommon = explode( '|', $con->js_common_name );
            foreach( $arrJsCommon as $jsCommonName )
            {
                    $jsCommonUrl = $baseUrl."/public/$con->js_common_dir/$jsCommonName";
                    $this->view->headScript()->appendFile( $jsCommonUrl );
            }

            //Add tiny_mce
            $this->view->headScript()->appendFile('/public/'.$con->js_common_dir.'/plugin/tiny_mce/tiny_mce.js');
            $this->view->headScript()->appendFile('/public/'.$con->js_common_dir.'/plugin/tiny_mce/config.js');

            $this->view->dateNow = $this->timeNow();
                
        }
        
        public function timeNow()
        {
            $date = new Zend_Date();
            $date->setTimezone('Asia/Ho_Chi_Minh');
            $part = Zend_Date::HOUR_SHORT_AM;
            $locale = 'vi_VN';
            Zend_Registry::set('datevn', $date->get($part,$locale));
            return $date;
        }
        
}